from django.conf.urls import url
from rest_framework.routers import DefaultRouter

from . import views
from rest_framework_jwt.views import obtain_jwt_token
from .views import statistical, users, specs, images, sku, \
    orders, permissions, groups, admins, spu, options, channels, brands


urlpatterns = [
    url(r'^authorizations/$', obtain_jwt_token),

    # 后台首页数据展示
    # 普通用户总数
    url(r'^statistical/total_count/$', statistical.UserTotalCountView.as_view()),
    # 日增用户数量
    url(r'^statistical/day_increment/$', statistical.UserDayCountView.as_view()),
    # 日活跃用户数量
    url(r'^statistical/day_active/$', statistical.UserActiveCountView.as_view()),
    # 日活跃用户数量
    url(r'^statistical/day_orders/$', statistical.UserOrderCountView.as_view()),
    # 月增用户数量
    url(r'^statistical/month_increment/$', statistical.UserMonthCountView.as_view()),
    # 月日分类商品访问量
    url(r'^statistical/goods_day_views/$', statistical.GoodsDayView.as_view()),

    # 用户数据展示和新增
    url(r'^users/$', users.UserView.as_view()),

    # 获取SPU简单信息
    url(r'^goods/simple/$', specs.SpecsView.as_view({'get': 'simple'})),

    # 获取SKU简单信息
    url(r'^skus/simple/$', images.ImageView.as_view({'get': 'simple'})),

    # 获取规格信息内容
    url(r'^goods/(?P<pk>\d+)/specs/$', sku.SKUGoodsView.as_view({'get': 'specs'})),

    # 获取权限类型
    url(r'^permission/content_types/$', permissions.PermissionView.as_view({'get': 'content_type'})),

    # 获取权限简单信息
    url(r'^permission/simple/$', groups.GroupView.as_view({'get': 'simple'})),

    # 获取分组简单信息
    url(r'^permission/groups/simple/$', admins.AdminView.as_view({'get': 'simple'})),

    # 获取分组品牌信息
    url(r'^goods/brands/simple/$', spu.SPUGoodsView.as_view({'get': 'simple'})),

    # 获取三级分类信息
    url(r'^goods/channel/categories/$', spu.SPUGoodsView.as_view({'get': 'first'})),
    url(r'^goods/channel/categories/(?P<pk>\d+)/$', spu.SPUGoodsView.as_view({'get': 'second'})),

    # 获取简单规格信息
    url(r'^goods/specs/simple/$', options.SpecificationOptionGoodsView.as_view({'get': 'simple'})),

    # 获取简单规格信息
    url(r'^goods/categories/$', channels.GoodsChannelView.as_view({'get': 'categories'})),

    # 获取简单规格信息
    url(r'^goods/channel_types/$', channels.GoodsChannelView.as_view({'get': 'channel_types'})),

]

# 规格表的增删改查
router = DefaultRouter()
router.register(r'goods/specs', specs.SpecsView, base_name='specs')
urlpatterns += router.urls

# 图片表的增删改查
router = DefaultRouter()
router.register(r'skus/images', images.ImageView, base_name='images')
urlpatterns += router.urls

# sku表的增删改查
router = DefaultRouter()
router.register(r'skus', sku.SKUGoodsView, base_name='skus')
urlpatterns += router.urls

# 订单表的增删改查
router = DefaultRouter()
router.register(r'orders', orders.OrderView, base_name='orders')
urlpatterns += router.urls

# 用户权限表的增删改查
router = DefaultRouter()
router.register(r'permission/perms', permissions.PermissionView, base_name='permission')
urlpatterns += router.urls

# 用户组表的增删改查
router = DefaultRouter()
router.register(r'permission/groups', groups.GroupView, base_name='groups')
urlpatterns += router.urls

# 管理员表的增删改查
router = DefaultRouter()
router.register(r'permission/admins', admins.AdminView, base_name='admins')
urlpatterns += router.urls

# 频道表的增删改查
router = DefaultRouter()
router.register(r'goods/channels', channels.GoodsChannelView, base_name='channels')
urlpatterns += router.urls

# 品牌表的增删改查
router = DefaultRouter()
router.register(r'goods/brands', brands.BrandView, base_name='brands')
urlpatterns += router.urls

# spu表的增删改查
router = DefaultRouter()
router.register(r'goods', spu.SPUGoodsView, base_name='goods')
urlpatterns += router.urls

# 规格选项表的增删改查
router = DefaultRouter()
router.register(r'specs/options', options.SpecificationOptionGoodsView, base_name='options')
urlpatterns += router.urls

